package main

import (
	_ "embed"
	"flag"
	"log"

	"gitee.com/xuender/pp"
	"gitee.com/xuender/pp/client"
	"github.com/syndtr/goleveldb/leveldb"
)

func main() {
	c := pp.NewConfig()

	flag.IntVar(&c.UDPPort, "udp", c.UDPPort, "UDP端口号")
	flag.IntVar(&c.RPCPort, "rpc", c.RPCPort, "RPC端口号")
	flag.StringVar(&c.UserID, "id", c.UserID, "用户ID")
	flag.StringVar(&c.Nick, "nick", c.Nick, "本人昵称")
	flag.Parse()

	db, err := leveldb.OpenFile("db", nil)
	if err != nil {
		log.Fatalln(err)
	}
	defer db.Close()

	if c.Nick == "" {
		c.Nick = "匿名"
	}

	if err := client.InitApp(c, db).Run(); err != nil {
		log.Fatalln(err)
	}
}
